package com.test.uiapp2.function.debugging;

import android.os.RemoteException;
import android.util.Log;

import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiSelector;

import com.test.uiapp2.base.TestBase;
import com.test.uiapp2.element.Base.BaseElement;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static junit.framework.Assert.fail;

public class debuggingFunction extends TestBase {
    public static void exeCmd(String commandStr) {
        BufferedReader br = null;
        try {
            Process p = Runtime.getRuntime().exec(commandStr);
            br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line = null;
            StringBuilder sb = new StringBuilder();
            while ((line = br.readLine()) != null) {
                sb.append(line + "\n");
            }
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally
        {
            if (br != null)
            {
                try {
                    br.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    //执行返回
    public  void preback(){
        uiDevice.swipe(1289,1648,1042,1670,STEP);
//        clickHome();
//        sleep(WAIT);
//        Log.i(TAG, "preback:执行home操作");
//        try {
//            uiDevice.executeShellCommand("am start -n  "+"com.wandoujia.phoenix2/com.pp.assistant.activity.PPMainActivity");
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

//            upSwip();
//            for (int i=0;i<=100;i++){
//                sleep(WAIT);
//                Log.i(TAG, "进入循环第"+i+"次");
//            }
//            verify("测试断言失败",getTest("哈哈哈哈哈").exists());

    }

    public void testlp(){
        try {
            if (!uiDevice.isScreenOn()){
                Log.i(TAG,"点亮屏幕");
                uiDevice.wakeUp();
                verify("未解锁屏幕",getTest("上滑解锁").exists());
            }
            Log.i(TAG, "当前为亮屏状态");
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

}
